﻿<%@ Page Language="C#"  Inherits="System.Web.Mvc.ViewPage"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>功能模块</title>


    <link rel="Stylesheet" type="text/css" href="/Manager/css/bitmapcutter/jquery.bitmapcutter.css" />
    <link rel="Stylesheet" type="text/css" href="/js/jquery/jquery.uploadify-v2.1.0/uploadify.css" />

</head>
    <body >
 <style type="text/css">
        #container
        {
        	width:800px;
        	height:500px;
        	margin:50px auto;
        	border:solid 1px #7d9edb;
        	display:none;
        	padding:5px;
        	}
    </style>
     <script type="text/javascript">
         var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>";
         var ASPSESSID = "<%= Session.SessionID %>";
             $("#uploadify").uploadify({
                 'uploader': '/js/jquery/jquery.uploadify-v2.1.0/uploadify.swf' + '?var=' + (new Date()).getTime(),
                 'script': '/manager/Normal_UploadImage/Update/2',
                 'cancelImg': '/js/jquery/jquery.uploadify-v2.1.0/cancel.png',
                 'folder': 'UploadFile',
                 'queueID': 'fileQueue',
                 'auto': false,
                 'multi': false,
                 'fileExt': '*.jpg;*.png',
                 'fileDesc': '请选择jpg , png文件...',
                 'scriptData': { 'ASPSESSID': ASPSESSID, 'AUTHID': auth },
                 'sizeLimit': 2097152,
                 'onComplete': function (event, queueID, fileObj, response, data) {
                     var width = 0;
                     var height = 0;
                     var list = $("#sltThumb").val().split("|");
                     width = parseInt(list[0]);
                     height = parseInt(list[1]);
                     if ($("#sltIsAuto").val() == '0') {
                         show2(width, height, response);
                         //
                     }
                     else {
                         alert(response);
                         show(width, height, response);
                     }
                 }
             });
           
         
    </script>

    
    <script type="text/javascript">
        function show(width, height, imageSrc) {
            $('#container').css("display", "block");
            $('#container').html('');

            $.fn.bitmapCutter({
                src: imageSrc,
                renderTo: '#container',
                cutterSize: { width: width, height: height },
                onGenerated: function (src) {
                    //alert('EditModule_Article<%=ViewData["id"].ToString() %>');
                    //console.log(Ext.getCmp('EditModule_Article<%=ViewData["id"].ToString() %>'));
                    //alert(Ext.getCmp('EditModule_Article<%=ViewData["id"].ToString() %>'));
                    Ext.getCmp('<%=ViewData["type"].ToString() %>Module_Article<%=ViewData["id"].ToString() %>').form.findField("Img").setValue(src);
                    Normal_UploadImageWin.close();
                },
                rotateAngle: 90,
                lang: { clockwise: '顺时针旋转{0}度.' }
            });

        }
        function show2(width, height, imageSrc) {

            $.ajax({
                url: '/manager/Normal_UploadImage/Insert/',
                dataType: 'json',
                data: { action: 'GenerateBitmap', src: imageSrc, zoom: 1, x: 0, y: 0, width: width, height: height, t: Math.random() },
                error: function (msg) {
                    alert('rotate failed!');
                },
                success: function (json) {
                    if (json.msg == 'success') {
                        alert('EditModule_Article<%=ViewData["id"].ToString() %>');
                        Ext.getCmp('EditModule_Article<%=ViewData["id"].ToString() %>').form.findField("Img").setValue(json.src);
                        Normal_UploadImageWin.close();
                    }
                    else {
                        alert(json.msg);
                    }
                }
            });
        }
    </script>
    <p> <div id="fileQueue"></div>
    <input type="file" name="uploadify" id="uploadify" />
   <select id="sltIsAuto"  >
      <option value="0">自动裁剪</option>
      <option value="1">手动裁剪</option>
    </select>
    <select id="sltThumb"  >
    <% List<CMN.Entity.Normal_ThumbnailEntity> thumbs = ( List<CMN.Entity.Normal_ThumbnailEntity>)ViewData["thumbs"];
       int thumbId = 0;
       if (ViewData["defaultThumbs"] != null)
       {
           thumbId = (int)ViewData["defaultThumbs"];
       }
         %>
         <%foreach (CMN.Entity.Normal_ThumbnailEntity thumb in thumbs)
           { %>
           <%if (thumb.Id == thumbId)
             { %>
               <option value="<%=string.Concat(thumb.IWidth.ToString(),"|",thumb.IHeight.ToString()) %>" selected><%=thumb.Title %></option>
           <%}
             else
             { %>
             <option value="<%=string.Concat(thumb.IWidth.ToString(),"|",thumb.IHeight.ToString()) %>" ><%=thumb.Title %></option>
           <%} %>

           <% } %>
    </select>
      <a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>| 
      <a href="javascript:$('#uploadify').uploadifyClearQueue()">取消上传</a>
    </p>
     <div id="container" ></div>
   
    </body>
</html>
